<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
        <script src="./js/jquery.min.js"></script>
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>会员管理</cite></a>
              <a><cite>问题/资讯列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
        <div class="demoTable x-center">    
				  名称：
				  <div class="layui-inline">
				    <input class="layui-input" name="par1" placeholder="请输入名称关键字" id="par1" autocomplete="off">
				  </div>
				  地址：
				  <div class="layui-inline">
				    <input class="layui-input" name="par2" placeholder="请输入地址关键字" id="par2" autocomplete="off">
				  </div>
				  <button class="layui-btn" data-type="reload">搜索</button> 
				</div>
           <!--  <form class="layui-form x-center" action="" style="width:800px">
                <div class="layui-form-pane" style="margin-top: 15px;">
                  <div class="layui-form-item">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div>
                    <div class="layui-input-inline">
                      <input type="text" name="username" id="username"  placeholder="标题" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form> -->
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button>
<!--             <button class="layui-btn" onclick="question_add('添加问题','question-add.html','600','500')"><i class="layui-icon">&#xe608;</i>添加</button> --> 
<span class="x-right" style="line-height:40px"></span></xblock>
           <table class="layui-table" lay-filter='test' id="demo">
              
            </table>

            <div id="page"></div>
        </div>
        <div  id="dd2"   style="display:none">
            <form class="layui-form" lay-filter="updateM1" >
            <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>编号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="id" name="id" required="" 
                        autocomplete="off" readonly="readonly" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>公司名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>公司介绍
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="describes" name="describes" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>公司文化
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="culture" name="culture" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                    <label for="role" class="layui-form-label">
                        <span class="x-red">*</span>邮箱
                    </label>
                    <div class="layui-input-inline">
                      <select name="role">
                        <option value="">请选择角色</option>
                        <option value="超级管理员">超级管理员</option>
                        <option value="编辑人员">编辑人员</option>
                        <option value="问题维护">问题维护</option>
                      </select>
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>公司电话
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="tel" name="tel" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>公司邮箱
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="email" name="email" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>公司地址
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="address" name="address" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>X轴坐标
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ext1" name="ext1" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>Y轴坐标
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="ext2" name="ext2" required="" 
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                        autocomplete="off" class="layui-input">
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <input class="layui-btn" value="修改" id="updatebtn">
                </div>
            </form>
        </div>
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script src="./js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use('table', function(){
  var table = layui.table;
  //第一个实例
  table.render({
    elem: '#demo'
    ,height: 412
    ,url: '../CompanyinfoServlet?oid=4' //数据接口
    ,page: true //开启分页
    ,cols: [[ //表头
    	{type:'checkbox', fixed: 'left'}
      ,{field: 'id', title: '编号', width:80, sort: true, fixed: 'left'}
      ,{field: 'name', title: '公司名称', width:80}
      ,{field: 'describes', title: '公司介绍', width:180}
      ,{field: 'culture', title: '公司文化', width:180}
      ,{field: 'tel', title: '公司电话', width:180}
      ,{field: 'email', title: '公司邮箱', width:180}
      ,{field: 'address', title: '公司地址', width:180}
      /* ,{field: 'ext1', title: 'x轴坐标', width:100} 
      ,{field: 'ext2', title: '是否显示', width:100}  */
      ,{fixed: 'right', width:250, align:'center', toolbar: '#barDemo'}

    ]]
  });
  
});
/*   <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> */
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  
</script>
<script type="text/javascript">
layui.use(["table","jquery"],function(){
  var table=layui.table;
  var $=layui.jquery;
   table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
  var data = obj.data; //获得当前行数据
  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
  var tr = obj.tr; //获得当前行 tr 的DOM对象
 
  if(layEvent === 'detail'){ //查看
    
  } else if(layEvent === 'del'){ //删除
      layer.open({
            type : 1,
            content : '<div style="padding: 20px 80px;">确定删除记录?</div>',
            btn : [ '确定', '取消' ],
            yes : function(index, layero) {
                $.ajax({
                    url : "delServlet",
                    data : {
                        "id" : data.id
                    },
                    dataType : "text",
                    success : function(r) {
                        if(r>0){
                            layer.msg("删除成功！");
                           obj.del();
                           layer.close(index);
                           table.reload("demo");
                        }else{
                            layer.msg("删除失败！");
                        }
                    },
                    error : function() {
                    }
                });
            }
        });

  } else if(layEvent === 'edit'){ //编辑
 var form=layui.form;//alert(data);
  	        form.val("updateM1",data);
				layer.open({
	            type : 1,
	            title:'修改页面',
	            content : $("#dd2"),
	            area: ['500px', '500px']
	        	});
  }
});
});
  
</script>
<script type="text/javascript">

$(function(){
$("#updatebtn").click(function(){
  var id = document.getElementById("id").value;
  var name = document.getElementById("name").value;
  var describes = document.getElementById("describes").value;
  var culture = document.getElementById("culture").value;
  var tel = document.getElementById("tel").value;
  var email = document.getElementById("email").value;
  var address = document.getElementById("address").value;
  var ext1 = document.getElementById("ext1").value;
  var ext2 = document.getElementById("ext2").value;
  
 $.post("../CompanyinfoServlet?oid=5",{
  id:id,
  name:name,
  describes:describes,
  culture:culture,
  tel:tel,
  email:email,
  address:address,
  ext1:ext1,
  ext2:ext2
  },function(r){
  if(r>0){
		 layer.msg("修改成功！");
		  window.setTimeout(function(){ 
		 window.location.href="javascript:location.replace(location.href)";
		 },600); 
		}else{
		 layer.msg("修改失败！");
		  window.setTimeout(function(){ 
         window.location.href="javascript:location.replace(location.href)";
          },600); 
	    }
  }); 
});

});



</script>
    </body>
</html>